<!DOCTYPE html>
<html lang="en-us">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
        <meta http-equiv="Content-Language" content="{$lang}">
        <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no, maximum-scale=1.0, user-scalabel=0">
        <title>{$site['html_title']}</title>
        <meta name="description" content="{$site['html_desc']}">
        <meta name="keywords" content="{$site['keywords']}">
        <script src="/static/js/layui/layui.js"></script>
        <script src="/static/js/public.js"></script>
        <link href="/static/js/layui/css/layui.css" rel="stylesheet">
        <link rel="stylesheet" href="/static/css/public.css">
        <link rel="shortcut icon" type="image/x-icon" href="{$site['icon_img']}">
        {block name="head"}{/block}
    </head>
    <body>
        {block name="header"}
        <div class="layui-header">
            <div class="layui-logo"><img src="/static/img/logo.png" alt=""></div>
            <ul class="layui-nav layui-layout-right">
                <li class="layui-nav-item"><a href="{:url('index/index')}">{:lang('home', [], $lang_label)}</a></li>
                {foreach $category as $v}
                <li class="layui-nav-item">
                    <a href="{if !$v['child']}{:url('index/category')}?category_id={$v['id']}{else}javascript:void(0);{/if}">{$v['title']}</a>
                    {if $v['child']}
                    <dl class="layui-nav-child">
                        {foreach $v['child'] as $v1}
                        <dd><a href="{:url('index/category')}?category_id={$v1['id']}">{$v1['title']}</a></dd>
                        {/foreach}
                    </dl>
                    {/if}
                </li>
                {/foreach}
                <li class="layui-nav-item">
                    <a href="javascript:void(0);">{:lang('language', [], $lang_label)}</a>
                    <dl class="layui-nav-child">
                        {foreach $language as $v}
                        <dd><a href="{:url('index/index')}?lang={$v['label']}">{$v['title']}</a></dd>
                        {/foreach}
                    </dl>
                </li>
            </ul>
        </div>
        {/block}
        {block name="body"}{/block}
        {block name="footer"}{/block}
        <div class="footer">
            {if isset($site['footer_desc'])}
            {:htmlspecialchars_decode($site['footer_desc'])}
            {/if}
        </div>
    </body>
    <script>
        window.onload = () => {
            // tp切换语言后页面必须刷新一次才能正确显示内容
            if(/lang=/.test(location.href)){
                let request = getRequest()
                let param = ''
                for(let key in request){
                    if(key == 'lang') continue
                    param += (param.length == 0 ? '?' : '&') + key + '=' + request[key]
                }
                location.href = location.origin + location.pathname + param
            }
        }
    </script>
</html>